package com.video.netty.InChannelHandler;

import com.alibaba.fastjson.JSONObject;
import com.video.commons.utils.GroupUtil;
import com.video.netty.commons.utils.ChannelUtil;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 获取组信息
 *  {"id":"getTerminalGroup"}
 * 返回
 * {"id": "terminalGroup","groups":
 *          [{"gname": "默认分组","level": 2,
 *              "clients": ["1", "2", "3"],
 *                  "groups": [{"gname": "分组1","level": 1,"clients": [],
 *                      "groups": [{"gname": "分组2","level": 0,"clients": ["4"],
 *                          "groups": []}]}]}]}
 */
@BaseChannelHandler.MsgHandler
public class WsGetTerminalGroupChannelHandler extends BaseChannelHandler {

    @Autowired
    private GroupUtil groupUtil;

    @Autowired
    private ChannelUtil channelUtil;

    @Override
    protected String msgId() {
        return "getTerminalGroup";
    }

    @Override
    protected void msgHandler(JSONObject json) {

        //获得群组信息
        String groupInfo = groupUtil.getGroupInfo();
        //发送群组消息
        channelUtil.sendMsg(groupInfo);
    }



}
